package main 

import (
	"os"
	"fmt"
	//"time"
	"os/signal"
	"syscall"
	"github.com/go-kratos/kratos/pkg/conf/paladin"
	di "store-assistant/internal/di"
)

func main() {
	fmt.Printf("[INFO] store-assistant start .. \n")
	paladin.Init()
	_, closeFunc, err := di.InitApp()
	if err != nil {
		panic(err)
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
	for {
		s := <-c
		fmt.Printf("[INFO] get a signal %s \n", s.String())
		switch s { 
		case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
			closeFunc()
			fmt.Printf("[INFO] store-assistant exit .. \n")
		case syscall.SIGHUP:
		default:
			return 
		}
	}
}
